/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2022/3/9
 * \* Time: 10:33
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */

class OuterClass2{
    public int data1 = 1;
    private int data2 = 2;
    public static int data3 = 3;
    //静态内部类
    static class InnerClass{
        public int data4 = 4;
        private int data5 = 5;
        public static int data6 = 6;

        //写一个构造方法
        public OuterClass2 out;
        public InnerClass(OuterClass2 out){
            this.out = out;
        }

        public void test(){
            //System.out.println(data1); //err
            System.out.println(out.data1);
            //System.out.println(data2);//err
            //System.out.println(new OuterClass2().data2); //由于是私有的，访问不了，要访问，只能提供get()和set()方法了
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
            System.out.println("InnerClass::test()");
        }
    }


}

class Test{
    public void test(){
        System.out.println("test()haha!");
    }
}

public class TestDemo2 {
    public static void main(String[] args) {
        new Test(){
            @Override
            public void test(){
                System.out.println("我是重写的test方法");
            }
        }.test();
    }


    public static void main1(String[] args) {
        OuterClass2 outerClass2 = new OuterClass2();
        OuterClass2.InnerClass innerClass = new OuterClass2.InnerClass(outerClass2);
        innerClass.test();

    }


}
